/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package calibracaolion;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

/**
 *
 * @author Santi
 */
@Entity
@Table(name = "fabricante", catalog = "geins", schema = "")
@NamedQueries({
    @NamedQuery(name = "Fabricante.findAll", query = "SELECT f FROM Fabricante f"),
    @NamedQuery(name = "Fabricante.findByCodFabricante", query = "SELECT f FROM Fabricante f WHERE f.codFabricante = :codFabricante"),
    @NamedQuery(name = "Fabricante.findByFabricante", query = "SELECT f FROM Fabricante f WHERE f.fabricante = :fabricante")})
public class Fabricante implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "cod_fabricante")
    private Integer codFabricante;
    @Basic(optional = false)
    @Column(name = "fabricante")
    private String fabricante;
    @OneToMany(mappedBy = "codFabricante")
    private List<Instrumentos> instrumentosList;

    public Fabricante() {
    }

    public Fabricante(Integer codFabricante) {
        this.codFabricante = codFabricante;
    }

    public Fabricante(Integer codFabricante, String fabricante) {
        this.codFabricante = codFabricante;
        this.fabricante = fabricante;
    }

    public Integer getCodFabricante() {
        return codFabricante;
    }

    public void setCodFabricante(Integer codFabricante) {
        Integer oldCodFabricante = this.codFabricante;
        this.codFabricante = codFabricante;
        changeSupport.firePropertyChange("codFabricante", oldCodFabricante, codFabricante);
    }

    public String getFabricante() {
        return fabricante;
    }

    public void setFabricante(String fabricante) {
        String oldFabricante = this.fabricante;
        this.fabricante = fabricante;
        changeSupport.firePropertyChange("fabricante", oldFabricante, fabricante);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (codFabricante != null ? codFabricante.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Fabricante)) {
            return false;
        }
        Fabricante other = (Fabricante) object;
        if ((this.codFabricante == null && other.codFabricante != null) || (this.codFabricante != null && !this.codFabricante.equals(other.codFabricante))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "calibracaolion.Fabricante[codFabricante=" + codFabricante + "]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }

}
